package com.wooboo.server.ext.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class UidHelper {

	public static String createUidFromPhone(String phone) {
		String content = phone+(System.currentTimeMillis()/1000);
		String uid = calculateMd5(content);
		return uid;
	}
	
	public static String calculateMd5(String content) {
        byte[] digesta = null;  
        try {  
            MessageDigest alga = MessageDigest.getInstance("MD5");  
            alga.update(content.getBytes());  
            digesta = alga.digest();  
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();  
        }  
        String rs = ByteHelper.byte2hex(digesta);  
        return rs; 
	}
    
    public static void main(String[] args) {
    	String phone = "13910934945";
    	String uid = createUidFromPhone(phone);
    	System.out.println(uid);
    }
}
